package com.imdroid.carac.process;

import java.util.Hashtable;

/**
 * The process factory.
 * 
 */
public class ProcessFactory {
	/**
	 * The inner hash table to store the views instances.
	 */
	private static Hashtable<Class<?>, BaseProcess> daos = new Hashtable<Class<?>, BaseProcess>();

	/**
	 * Return the single service instance.
	 * 
	 * @param processClass
	 *            The service class
	 * @return The service instance.
	 */
	public static BaseProcess getProcess(Class<?> processClass) {
		BaseProcess process = (BaseProcess) daos.get(processClass);

		if (process == null) {
			try {
				process = (BaseProcess) processClass.newInstance();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
			daos.put(processClass, process);
		}

		return process;
	}
}
